#include "stream.h"
#include "process_mgmt.h"
#include "wnds_mgmt.h"
#include "wnds_proc.h"

using namespace std;


BOOL CALLBACK EnumWndProc(HWND hwnd, __in LPARAM lParam)
{
    if(lParam == NULL)
        return FALSE;

    window_search *wnd = (window_search*)(lParam);
    wnd->analyze_element(window_info(hwnd)); 
    return TRUE;
}

LRESULT CALLBACK WndProc1(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     switch (message)
     {
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
        case WM_CLOSE:
            break;
        case WM_CREATE:
            break;
        case WM_LBUTTONDOWN:
            stream::system_message("wnds_proc", "windproc1");
            break;
        case WM_KEYDOWN:
            break; 
     }

     return DefWindowProc(hwnd, message, wParam, lParam);
}

LRESULT CALLBACK WndProc2(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     switch (message)
     {
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
        case WM_CLOSE:
            break;
        case WM_CREATE:
            break;
        case WM_LBUTTONDOWN:
            stream::system_message("wnds_proc", "windproc2");
            break;
        case WM_KEYDOWN:
            break; 
     }

     return DefWindowProc(hwnd, message, wParam, lParam);
}


LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     //cout<<endl<<"Callback msg: "<<message<<" : "<<wParam<<" : "<<wParam<<endl;

     switch (message)
     {
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
        case WM_CLOSE:
            break;
        case WM_CREATE:
            //ShowCursor(false);
            break;
        case WM_SETCURSOR:
            break;
        case WM_ERASEBKGND:
            if(isWndProcUpdateBlockadeActive() == TRUE)
                return 0;
            processes::event_signal(window_text::wndTextEvent);
            break;
        case WM_PAINT: 
            return 0;
            break;
        case WM_KILLFOCUS:
            break;
        case WM_LBUTTONDOWN:
            break;
        case WM_TIMER:
/*         switch(wParam) {
               case IDT_TIMER2: 
                    bringConsoleForeground();
                    bringWindowForeground(hwnd);

                    break;
            }
*/
            break;
     }

     return DefWindowProc(hwnd, message, wParam, lParam);
}

